require_relative 'lib/checker'

MOVE_TIMES = 1000

def rand_move(moves)
  moves[rand(moves.size)]
  # moves.first
end

def test
  checker = Checker.new
  checker.show

  MOVE_TIMES.times do |idx|
    byebug
    # if idx.eql? 89
    #   byebug
    #   puts '++++++++++++++++++++++'
    # end
    rtn = checker.possible_moves
    puts "#{idx}\t#{checker.player}\t#{rtn.inspect}"

    if rtn.empty?
      puts "failed, player: #{checker.player}"
      return
    end

    move = rand_move(rtn)
    checker.move *move
    checker.show
  end
end

def show_next(idx, player, rtn)
  puts "次数\t玩家\t可移动的位置"
  puts "#{idx}\t#{checker.player}\t#{rtn.inspect}"
end

require 'byebug'
# byebug
# puts "间隔棋子之后跳到下一个位置"
# puts "次数\t玩家\t可移动的位置"
test
# puts "++++++++++++++++++++++++\n"
